# -*- coding: utf-8 -*-
import numpy as np

if __name__ == '__main__':
    file_name ="../presidential_polls.csv"
    loadtxt = np.loadtxt(fname=file_name,
                         delimiter=",",  # 分隔符
                         dtype=str,  # 数据类型
                         usecols=(0, 2, 3)  # 指定读取的索引列
                         )
    print loadtxt,loadtxt.shape
    print "===================================="
    np_loadtxt = np.loadtxt(fname=file_name,
                            delimiter=",",  # 分隔符
                            skiprows=1,  # 跳过的行
                            dtype={"names": ('cycle', 'type', 'matchup'),
                                   "formats": ('i4', 'S15', 'S50')},
                            usecols=(0, 2, 3)
                            )
    print np_loadtxt, np_loadtxt.shape
